/*
 * bmpTest2.c
 *
 *  Created on: May 21, 2013
 *      Author: koldar
 */

#include <stdio.h>
#include <stdlib.h>
#include "solution.h"
#include "graph.h"
#include "ltm.h"
#include "parser.h"
#include "graphbmp-tools.h"

int main(int argn,const char** args){

	FILE* graphfile;
	FILE* bmpfile;
	int N;
	int K;
	Pgraph pgraph;
	Psolution psolution;
	printf("parametri: %d\n",argn);
	if (argn==3){
			graphfile=fopen(args[1],"r");
			bmpfile=fopen(args[2],"w");
		}else{
			printf("numero di parametri passati errati.\n");
			return EXIT_FAILURE;
		}
	printf("parso il file...\n");
	pgraph=parseGraph(graphfile,&N);
	K=2;
	dijkstraFiller(pgraph);
	initSmartWeights(pgraph);
	PedgeID _12=initEdgeID(0,1);
	PedgeID _23=initEdgeID(1,2);
	PedgeID _34=initEdgeID(2,3);
	PedgeID _40=initEdgeID(3,0);
	PedgeID _17=initEdgeID(0,6);
	PedgeID _78=initEdgeID(6,7);
	PedgeID _84=initEdgeID(7,3);
	PedgeID _46=initEdgeID(3,5);
	PedgeID _620=initEdgeID(5,19);
	PedgeID _201=initEdgeID(19,0);
	validateEdgeID(_12);
	validateEdgeID(_23);
	validateEdgeID(_34);
	validateEdgeID(_40);
	printf("creo la soluzione...\n");
	psolution=initSolution(&K,&N);

	addEdgeToVehicleState(_620,getEdgeGraph(pgraph,_620),getVehicleStateInSolution(psolution,0),true);
	addEdgeToVehicleState(_620,getEdgeGraph(pgraph,_620),getVehicleStateInSolution(psolution,1),false);
	addEdgeToVehicleState(_84,getEdgeGraph(pgraph,_84),getVehicleStateInSolution(psolution,0),true);
	//addEdgeInVehicleState(_12,getEdge(pgraph,_12),getVehicleStateInSolution(psolution,0),true);
	/*addEdgeIDInSolution(solution,0,_12,&graph->am[_12->i][_12->j],true);
	addEdgeIDInSolution(solution,0,_23,&graph->am[_23->i][_23->j],true);
	addEdgeIDInSolution(solution,0,_34,&graph->am[_34->i][_34->j],true);
	addEdgeIDInSolution(solution,0,_40,&graph->am[_40->i][_40->j],true);

	addEdgeIDInSolution(solution,1,_17,&graph->am[_17->i][_17->j],true);
	addEdgeIDInSolution(solution,1,_78,&graph->am[_78->i][_78->j],true);
	addEdgeIDInSolution(solution,1,_84,&graph->am[_84->i][_84->j],true);
	addEdgeIDInSolution(solution,1,_46,&graph->am[_46->i][_46->j],true);
	addEdgeIDInSolution(solution,1,_620,&graph->am[_620->i][_620->j],true);
	addEdgeIDInSolution(solution,1,_201,&graph->am[_201->i][_201->j],true);*/
	//printf("faccio la costruttiva...\n");
	//simpleConstructive(graph,solution);
	printf("disegno la soluzione...\n");
	drawSolutionFromScratch(
					"pictures/bmpTest2.bmp",
					psolution,
					pgraph->depot,
					15,
					15,
					7,
					1,
					4,
					2,
					1,
					COLOR_BLACK,
					COLOR_DARK_GREY,
					COLOR_VIOLET);
	printf("ho finito!\n");
	fclose(graphfile);
	fclose(bmpfile);
	printf("FINE.\n");
}
